<?php

namespace app\common\model\xiservice;

use think\Model;


class Withdraw extends Model
{

    

    

    // 表名
    protected $name = 'xiservice_user_withdraw';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'checkinfo_text',
        'createtime_text'
    ];
    

    
    public function getCheckinfoList()
    {
        return ['0' => __('Checkinfo 0'), '1' => __('Checkinfo 1'), '2' => __('Checkinfo 2')];
    }


    public function getCheckinfoTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['checkinfo']) ? $data['checkinfo'] : '');
        $list = $this->getCheckinfoList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getCreatetimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['createtime']) ? $data['createtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i", $value) : $value;
    }


    public function user()
    {
        return $this->belongsTo('app\common\model\xiservice\User', 'user_id', 'user_id', [], 'LEFT')->setEagerlyType(0);
    }
}
